﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Windows;

namespace CCF20Model
{
    partial class SMSTemplate : IDataErrorInfo
    {

        public SMSTemplate()
        {
            this.ModifiedTime = DateTime.Now;
            try
            {
                this.Operator = (string)Application.Current.Properties["CurrentUser"];
            }
            catch
            {
                this.Operator = "System";
            }
        }

        
        #region IDataErrorInfo Members

        private Dictionary<string, string> m_validationErrors = new Dictionary<string, string>();

        private void AddError(string columnName, string msg)
        {
            if (!m_validationErrors.ContainsKey(columnName))
            {
                m_validationErrors.Add(columnName, msg);
            }

        }

        private void RemoveError(string columnName)
        {
            if (m_validationErrors.ContainsKey(columnName))
            {
                m_validationErrors.Remove(columnName);
            }
        }

        public string Error
        {
            get
            {
                if (m_validationErrors.Count > 0)
                {
                    return "Customer data is invalid";
                }
                else return null;
            }
        }

        public string this[string columnName]
        {
            get
            {
                if (m_validationErrors.ContainsKey(columnName))
                {
                    return m_validationErrors[columnName];
                }
                else return null;
            }
        }

        #endregion
    }
}
